<?php

class Core_Backend_Component_Customer_View_Map_Create extends Core_Backend_Share_View_Form {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('customer/index/index'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.submit'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'submit') . "')");
        $group->addButton($this->__('share.button.apply'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'apply') . "')");
        $group->addButton($this->__('share.button.save'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'save') . "')");
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('map_form')
                ->addHiddenField('id', 'map[id]')
                ->addHiddenField('poi_id', 'map[poi_id]', $this->getPoi()->getId());
        $form->addSelectField($this->__('customer.label.window_template'), 'window_template', 'map[window_template]')
                ->setOption($this->__('share.label.default_template'), 'default');
        $form->addFileBrowserField($this->__('customer.label.balloon_image'), 'balloon_image', 'map[balloon_image]')
                ->setPath('pub/media/road/' . $this->getPoi()->getRoadId() . '/' . $this->getPoi()->getId() . '/balloon')
                ->setFileType('image')
                ->setCallback('selectMapLogo');

        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
        }
        parent::buildForm($form);
    }

}